home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Warrior’s Progress / source code / Source / Libraries / Drawing / PointObject.h < prev    next >
Encoding:
Text File  |  1997-06-28  |  1.9 KB  |  66 lines  |  [TEXT/CWIE]

  1. // PointObject.h
  2.  
  3. #ifndef PointObject_h
  4. #define PointObject_h
  5.  
  6. #ifndef Integers_h
  7. #include "Integers.h"
  8. #endif
  9.  
  10. class PointObject: public Point
  11.   {
  12.     public:
  13.         PointObject()                                                    {}
  14.         PointObject( Point p )                    : Point( p )    {}
  15.         PointObject( int16 x, int16 y )                            { h = x; v = y; }
  16.         
  17.         static const PointObject zero;
  18.         
  19.         static const PointObject up;
  20.         static const PointObject left;
  21.         static const PointObject down;
  22.         static const PointObject right;
  23.         
  24.         static const PointObject upLeft;
  25.         static const PointObject upRight;
  26.         static const PointObject downLeft;
  27.         static const PointObject downRight;
  28.  
  29.         void operator=( Point p )                        { *(Point *)this = p; }
  30.         
  31.         bool operator==( PointObject r ) const        { return h == r.h && v == r.v; }
  32.         bool operator!=( PointObject r ) const        { return h != r.h || v != r.v; }
  33.         
  34.         bool AboveLeftOf( PointObject r ) const    { return h >= r.h && v >= r.v; }
  35.         bool BelowLeftOf( PointObject r ) const    { return h >= r.h && v <= r.v; }
  36.         bool AboveRightOf( PointObject r ) const    { return h <= r.h && v >= r.v; }
  37.         bool BelowRightOf( PointObject r ) const    { return h <= r.h && v <= r.v; }
  38.         
  39.         void BeAboveLeftOf( PointObject r );
  40.         void BeBelowLeftOf( PointObject r );
  41.         void BeAboveRightOf( PointObject r );
  42.         void BeBelowRightOf( PointObject r );
  43.         
  44.         void operator+=( PointObject r );
  45.         void operator-=( PointObject r );
  46.         void operator*=( int16 n );
  47.         void operator/=( int16 n );
  48.         
  49.         PointObject operator+() const                    { return *this; }
  50.         PointObject operator-() const;
  51.         PointObject operator+( PointObject r ) const;
  52.         PointObject operator-( PointObject r ) const;
  53.         PointObject operator*( int16 n ) const;
  54.         PointObject operator/( int16 n ) const;
  55.         
  56.         uint32 NormSquared() const;
  57.         uint32 TaxicabNorm() const;
  58.         
  59.         uint32 TaxicabDistanceTo( Point ) const;
  60.         
  61.         void GlobalToLocal()            { ::GlobalToLocal( this ); }
  62.         void LocalToGlobal()            { ::LocalToGlobal( this ); }
  63.   };
  64.  
  65. #endif
  66.